package com.situ.company.controller;

import com.situ.company.entity.Employee;
import com.situ.company.service.Impl.EmployeeService;
import com.situ.company.service.Impl.service.Impl.EmployeeServiceImpl;
import com.situ.company.vo.TableVO;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/employee")
public class EmployeeController extends BaseController{

    EmployeeService service =  new EmployeeServiceImpl();

    //打开页面
    public void page(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //查数据,带上
        req.getRequestDispatcher("/WEB-INF/employee.jsp").forward(req,resp);
    }

    public TableVO select(Integer page, Integer limit, String name, String tel) {


        return service.select(page,limit,name,tel);
        //查出来商品的数据

        //把数据返回给table小工具(响应)
        //获取一个响应的前台写出对象
        //list转完后是[{},{},{}]



        //dao统计一个数，一共都少条数据

        //使用json工具把对象转成json格式的字符串
        //fastjson 和 jackson
        //通过jackson工具把list对象转成json 字符串


    }
    public void save(Employee e){
        service.save(e);

    }

    public void delete(Integer id){
        service.delete(id);
    }


    //编辑
    public Employee info(Integer id) {

        return service.info(id);
    }
}
